package com.example.homemodule.adapter;

import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;

import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.homemodule.model.bean.PrivateDoctorEntity;
import com.example.homemodule.R;

import java.util.List;

/**
 * Created by SHICHENG
 * <p>
 * Time on 2022/01/04
 */
public class PrivateDoctorAdapter extends BaseQuickAdapter<PrivateDoctorEntity.DataBean.MyDoctorVOListBean, BaseViewHolder> {
    public PrivateDoctorAdapter(@Nullable List<PrivateDoctorEntity.DataBean.MyDoctorVOListBean> data) {
        super(R.layout.item_private_doctor, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, PrivateDoctorEntity.DataBean.MyDoctorVOListBean item) {
//        ALog.e("oakkk","doctorEntity: " + new Gson().toJson(item));

        if (item.isBzShow()){
            helper.setTextColor(R.id.private_name,mContext.getResources().getColor(R.color.color_A46E1A));
            helper.setTextColor(R.id.private_title,mContext.getResources().getColor(R.color.color_A46E1A));
            helper.setTextColor(R.id.private_hospitalname,mContext.getResources().getColor(R.color.color_A46E1A));
            helper.setBackgroundRes(R.id.private_doctor_ask,R.drawable.btn_enable);
            helper.setBackgroundRes(R.id.private_doctor_bg,R.mipmap.bg_doctor_card_bz);
            helper.getView(R.id.private_doctor_bz_avatar).setVisibility(View.VISIBLE);
        }else{
            helper.setTextColor(R.id.private_name,mContext.getResources().getColor(R.color.color_333));
            helper.setTextColor(R.id.private_title,mContext.getResources().getColor(R.color.color_333));
            helper.setTextColor(R.id.private_hospitalname,mContext.getResources().getColor(R.color.color_333));
            helper.setBackgroundRes(R.id.private_doctor_ask,R.drawable.btn_normal_enable);
            helper.setBackgroundRes(R.id.private_doctor_bg,R.mipmap.bg_doctor_card);
            helper.getView(R.id.private_doctor_bz_avatar).setVisibility(View.INVISIBLE);
        }
        helper.addOnClickListener(R.id.private_doctor_ask);
        Glide.with(mContext).load(item.getAvatar())
                .transform(new CenterCrop(), new CircleCrop())
                .into((ImageView) helper.getView(R.id.private_avator));
        helper.setText(R.id.private_name,item.getName());
        if (!TextUtils.isEmpty(item.getHospitalName())) {
            helper.setText(R.id.private_hospitalname, item.getHospitalName());
        }else {
            helper.setText(R.id.private_hospitalname, "");
        }
    }
}
